home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0574.ZIP
/
_STRHAND.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-11-21
|
936b
|
52 lines
include compiler.inc
ttl $STRHAND, 1.01, 08-03-86 clr
; internal routine to convert stream pointer to handle. If bad handle, returns
; AX=-1; else returns handle in AX. Returns state of MODE BIT (offset 2 in _ftb
; in BL register, state of UGC (word) in CX
dseg
exterr
extrn _ftb:byte
cseg
procdef $strhand <<stream,ptr>>
pushreg
pushds
mov si,offset _ftb
ldptr ax,stream,ds
mov dx,ds
or dx,ax
jz invalid
mov di,ax ;save stream pointer
sub ax,si ;convert to handle
jz nodiv
mov si,5
cwd
div si
nodiv: xor dx,dx ;clear error code
moverr dx
cmp ax,0 ;check range
jl seterr
cmp ax,19 ;20 handles is DOS max
jl ok
seterr:
or byte ptr 2[di],10h ; set error code
mov ax,-1 ;and return ERROR
ok:
mov bl,byte ptr 2[di] ; return MODE BIT
mov cx,word ptr [di] ; return UGC BYTE
out1:
pret
invalid:
mov ax,-1
jmp short out1
pend $strhand
finish